﻿<%@ Page Language="C#" AutoEventWireup="true" Inherits="_Default" Codebehind="Default.aspx.cs" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Modelli</title>
    <link href="css/cupertino/jquery-ui-1.8.18.custom.css" rel="stylesheet" type="text/css" />
    <script src="../JS/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script src="../JS/jquery-ui-1.8.18.custom.min.js" type="text/javascript"></script>
    <script src="../js/knockout-2.0.0.js" type="text/javascript"></script>
    <script src="../js/knockout.mapping-latest.js" type="text/javascript"></script>
    <script src="../JS/jquery.noty.js" type="text/javascript"></script>
    <script src="../JS/jquery.ui.combobox.js" type="text/javascript"></script>
    <script src="../JS/linq.min.js" type="text/javascript"></script>
    <script src="../JS/GenesiLib.js" type="text/javascript"></script>
    <script src="js/jquery.ui.combobox.js" type="text/javascript"></script>
    <style type="text/css">
	.ui-combobox {
		position: relative;
		display: inline-block;
	}
	.ui-button {
		position: absolute;
		top: 0;
		bottom: 0;
		margin-left: -1px;
		padding: 0;
		/* adjust styles for IE 6/7 */
		*height: 1.7em;
		*top: 0.1em;  
	}
	.ui-autocomplete-input {
		margin: 0;
		padding: 0.3em;
	}
	</style>
    <script type="text/javascript">
        $(function () {
            $('#nuovo').hide();
            $('#showNew').click(function () {
                $('#nuovo').toggle('slow', function () {
                    // Animation complete.
                    if ($('#showNew').val() == "Nuovo") {
                        $('#showNew').val("Annulla");
                    }
                    else {
                        $('#showNew').val("Nuovo");
                    }
                });
            });

            $('#<%=ddFornitori.ClientID %>').append(
                            $('<option></option>').val("").html("")
                         );
            $('#<%=ddFornitori.ClientID %>').combobox();

            $('#<%=ddArticoli.ClientID %>').append(
                            $('<option></option>').val("").html("")
                         );
            $('#<%=ddArticoli.ClientID %>').combobox();
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div style="float: right">
            <input type="button" id="showNew" class="ui-widget ui-state-default ui-corner-all ui-button-text-only"
                value="Nuovo" />
        </div>
        <div style="float: left">
            Fornitore:
            <asp:DropDownList ID="ddFornitori" runat="server" DataTextField="Fornitore" DataValueField="id">
            </asp:DropDownList>
        </div>
        <div style="text-align: center">
            Articoli:
            <asp:DropDownList ID="ddArticoli" runat="server" DataTextField="descrizione" DataValueField="id">
            </asp:DropDownList>
        </div>
        <div id="nuovo">
            <div style="text-align: right">
                <asp:Button ID="btnFiltra" Text="Filtra" runat="server" CssClass="ui-widget ui-state-default ui-corner-all ui-button-text-only"
                    OnClick="btnFiltra_Click" />
            </div>
            <asp:GridView ID="dispo" runat="server" DataKeyNames="id" AutoGenerateColumns="false"
                AllowPaging="true" PageSize="10" Width="80%" OnRowCommand="Associa">
                <Columns>
                    <asp:BoundField HeaderText="Cod" DataField="CodArt" />
                    <asp:BoundField HeaderText="Art" DataField="descrizione" />
                    <asp:BoundField HeaderText="Prezzo" DataField="PrezzoUnitario" />
                    <asp:BoundField HeaderText="U.M." DataField="DescUnitaMisura" />
                    <asp:BoundField HeaderText="Iva" DataField="Iva" />
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:ImageButton ID="btnLink" runat="server" ImageUrl="Images/apply.png" CommandName="Associa"
                                CommandArgument='<%# Eval("id") %>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <asp:GridView ID="gvAssociati" runat="server" DataKeyNames="id" AutoGenerateColumns="false"
                AllowPaging="true" PageSize="10" Width="80%" OnRowCommand="DeAssocia">
                <Columns>
                    <asp:BoundField DataField="id" Visible="false" />
                    <asp:BoundField HeaderText="Cod" DataField="CodArt" />
                    <asp:BoundField HeaderText="Art" DataField="descrizione" />
                    <asp:BoundField HeaderText="Prezzo" DataField="PrezzoUnitario" />
                    <asp:BoundField HeaderText="U.M." DataField="DescUnitaMisura" />
                    <asp:BoundField HeaderText="Iva" DataField="Iva" />
                    <asp:TemplateField HeaderText="Quantità">
                        <ItemTemplate>
                            <asp:TextBox ID="txtQTA" runat="server"></asp:TextBox>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:ImageButton ID="btnLink" runat="server" ImageUrl="Images/delete.png" CommandName="DeAssocia"
                                CommandArgument='<%# Eval("id") %>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <div>
                Nome Modello :
                <asp:TextBox ID="nomeNew" runat="server" MaxLength="50" /><asp:RequiredFieldValidator
                    ID="RequiredFieldValidator1" runat="server" ErrorMessage="* Obbligatorio" ControlToValidate="nomeNew"
                    ValidationGroup="NuovoModello"></asp:RequiredFieldValidator><br />
                Descrizione :
                <asp:TextBox ID="descrizioneNew" runat="server" MaxLength="50" TextMode="MultiLine"
                    Rows="5" Columns="20"></asp:TextBox>
                <asp:Button ID="btnSave" Text="Salva" runat="server" CssClass="ui-widget ui-state-default ui-corner-all ui-button-text-only"
                    OnClick="SalvaModello" ValidationGroup="NuovoModello" />
            </div>
        </div>
        <div id="Modelli">
            <asp:GridView ID="gvModelli" runat="server" AllowSorting="true" AllowPaging="true"
                AutoGenerateColumns="false" OnRowCommand="gvModelliCommand" OnPageIndexChanging="gvModelli_PageIndexChanging"
                OnSorting="gvModelli_Sorting"  Width="80%">
                <Columns>
                    <asp:BoundField DataField="nome" HeaderText="Nome" />
                    <asp:BoundField DataField="descrizione" HeaderText="Descrizione" />
                    <asp:BoundField DataField="dataCreazione" DataFormatString="{0:dd/MM/yyyy}" HeaderText="Creato" />
                    <asp:TemplateField HeaderText="Elimina">
                        <ItemTemplate>
                            <asp:ImageButton ID="btnDel" runat="server" ImageUrl="Images/Icon_Cancel.png" CommandName="Elimina"
                                CommandArgument='<%# Eval("id") %>' AlternateText="Elimina Modello" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Converti">
                        <ItemTemplate>
                            <asp:ImageButton ID="btnConvert" runat="server" ImageUrl="Images/Icon_Clone.png"
                                CommandName="Convert" CommandArgument='<%# Eval("id") %>' AlternateText="Converti Modello in Ordine" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Modifica">
                        <ItemTemplate>
                            <asp:ImageButton ID="btnModifica" runat="server" ImageUrl="Images/details.gif" CommandName="Modify"
                                CommandArgument='<%# Eval("id") %>' AlternateText="Modifica Modello" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
        </div>
    </div>
    </form>
</body>
</html>
